package edu.sju.chenshu.friend.controller.user;

import edu.sju.chenshu.common.core.constants.HttpConstants;
import edu.sju.chenshu.common.core.domain.Result;
import edu.sju.chenshu.common.core.domain.TableDataInfo;
import edu.sju.chenshu.friend.domain.exam.dto.ExamDTO;
import edu.sju.chenshu.friend.domain.exam.dto.ExamQueryDTO;
import edu.sju.chenshu.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
public class UserExamController {
    @Autowired
    private IUserExamService userExamService;

    @PostMapping("/enter")
    public Result<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody ExamDTO examDTO) {
        return userExamService.enter(token, examDTO.getExamId());
    }

    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return userExamService.list(examQueryDTO);
    }
}
